package org.shj.thread.book2.chapter09;

public class FutureData implements Data{

	private RealData real = null;
	private boolean ready = false;
	
	public synchronized void setRealData(RealData real){
		if(ready){
			return;
		}
		
		this.real = real;
		
		this.ready = true;
		notifyAll();
	}
	
	public synchronized String getContent(){
		while(!ready){
			try{
				wait();
			}catch(InterruptedException e){
				
			}
		}
		return real.getContent();
	}
}
